package
{

	import flash.display.MovieClip;

public dynamic class WeaponCrate extends MovieClip
{
    var grav: Number = 1.2;
    var EF;
	/*
    var _name;
    var _parent;
    var _rotation;
    var _x;
    var _y;
	*/
    var caughtPlayer;
//    var hitTest;
    var num;
    var xv;
    var yv;

    function WeaponCrate()
    {
        super();
    }

    function init()
    {
        this.num = Number(this.name.substr(6, this.name.length - 6));
        this.xv = 0;
        this.yv = 2;
        this.x = 50 + Math.random() * 500;
        this.y = -20;
        this.EF = this.fallEF;
        this.caughtPlayer = [];
    }

    function fallEF()
    {
        this.x = this.x + this.xv;
        this.y = this.y + this.yv;
        if (this.parent.parent.ground.hitTest(this.x, this.y, true)) 
        {
            this.hitGround();
        }
        if (this.x < -10 || this.x > 610 || this.y > 460) 
        {
            this.parent.parent.removeObject(this);
        }
        this.hitCheck();
    }

    function hitCheck()
    {
        if (!this.parent.parent.cursorBusy && !this.parent.parent.paused && this.hitTest(this.parent._xmouse, this.parent._ymouse)) 
        {
            this.EF = null;
            SoundManager.startSound("ding");
            this.parent.parent.getWeapon();
        }
    }

    function getMe()
    {
        if (!this.parent.parent.cursorBusy && !this.parent.parent.paused) 
        {
            this.parent.parent.removeObject(this);
        }
    }

    function hitGround()
    {
        var __reg2 = this.parent.parent.findPathPoint(this.x);
        this.y = this.parent.parent.pointsA[__reg2].y;
        this.rotation = this.getGroundA(__reg2);
        this.EF = this.hitCheck;
    }

    function getGroundA(p)
    {
        if (p == 0) 
        {
            ++p;
        }
        if (p == this.parent.parent.pointsA.length - 1) 
        {
            --p;
        }
        var __reg3 = MyMath.getAngle(this.parent.parent.pointsA[p - 1].x, this.parent.parent.pointsA[p - 1].y, this.parent.parent.pointsA[p + 1].x, this.parent.parent.pointsA[p + 1].y);
        return __reg3;
    }

}


}